package com.kl.forum.api;


import com.kl.forum.enums.ResultCode;
import com.kl.forum.service.NoviceTaskService;
import com.kl.forum.util.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Api("新手任务")
@RestController
@RequestMapping("/novice")
public class NoviceControllerAPI {
    @Autowired
    private NoviceTaskService noviceTaskService;

    /**
     * 页面数据
     *
     * @return {"msg":"获取数据成功","code":200,"data":{"runGame":1,"coins":1000,"like":1,"mobile":1,"dailyTask":1,"withDraw":1,"shareMoney":1,"sharePost":1,"sign3Days":1,"award":1,"post":1,"beLiked":1,"comment":1}}
     */
    @ApiOperation(value = "页面数据",notes="")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/pageInfo",method= RequestMethod.GET)
    public ResultInfo pageInfo(Integer userId) {
            ResultInfo resultInfo = noviceTaskService.pageInfo(userId);
            return  resultInfo;
    }

    /**
     * 领取奖励
     *
     * @return {"msg":"您已经领取了奖励，不能重复领取","code":200}
     */
    @ApiOperation(value = "领取奖励",notes="")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/takeAward",method= RequestMethod.POST)
    public ResultInfo takeAward(Integer userId) {
        ResultInfo re=new ResultInfo();
        String str = noviceTaskService.takeAward(userId);
        re.setData(str);
        re.setMessage(ResultCode.SUCCESS.getMsg());
        re.setCode(ResultCode.SUCCESS.getCode());
        return  re;
    }

    /**
     * 判断是否已经全部完成（没领取就弹出红包）
     *
     * @param
     * @return {"msg":"判断完成","code":200,"data":true} {"msg":"判断完成时发生错误","code":-1}
     */
    @ApiOperation(value = "判断是否已经全部完成",notes="")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/checkFinish",method= RequestMethod.POST)
    public ResultInfo checkFinish(Integer userId) {
        ResultInfo re = noviceTaskService.checkFinish(userId);
        return re;
    }
}
